package com.xiaoke.service.impl;

import com.xiaoke.entity.Admin;
import com.xiaoke.mapper.AdminMapper;
import com.xiaoke.service.AdminService;
import com.xiaoke.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;

    @Override
    public Admin selectByPrimaryKey(String id) {
        return adminMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insert(@RequestBody Admin record) {
        record.setId(String.valueOf(snowflakeIdWorker.nextId()));
        adminMapper.insert(record);
    }

    @Override
    public void update(@RequestBody Admin record) {
        adminMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public void delete(String id) {

    }

    @Override
    public List<Admin> findByParams(@RequestBody Map<String, Object> params) {
        return adminMapper.findByParams(params);
    }
}
